import { SkillRuneHandbookTabItem } from "./SkillRuneHandbookTabItem";
import { SkillRuneHandbookTabData } from "../compose/SkillRuneHandbookTabData";
import { ObjCreate } from "../../../common/ObjCreate";
type int = number;
//class SkillRuneHandbookTabbar
    
    export  class SkillRuneHandbookTabbar /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._items = [];
            this.initView();
            return;
        }

        public customExpandCategory(arg1: int): void
        {
            if (arg1 < 0 || arg1 > this._items.length) 
            {
                arg1 = 0;
            }
            this._curItem = this._items[arg1] as SkillRuneHandbookTabItem;
            this.expandItem(this._curItem.data.type);
            return;
        }

        public set data(arg1: Array<any>)
        {
            var loc2=null;
            var loc3=null;
            var loc1=0;
            while (loc1 < arg1.length) 
            {
                loc2 = arg1[loc1] as SkillRuneHandbookTabData;
                (loc3 = new SkillRuneHandbookTabItem(loc2)).x = 0;
                loc3.y = 35 * loc1;
                this.addChild(loc3);
                this._items.push(loc3);
                ++loc1;
            }
            this.updatePlace();
            return;
        }

        public getCurType(): int
        {
            if (this._curItem) 
            {
                return this._curItem.data.type;
            }
            return SkillRuneHandbookTabItem(this._items[0]).data.type;
        }

        public getCurSubName(): string
        {
            if (!this._curItem) 
            {
                this._curItem = this._items[0] as SkillRuneHandbookTabItem;
            }
            return this._curItem.selectedName;
        }

        public setCurSubTab(arg1: int): void
        {
            if (!this._curItem) 
            {
                this._curItem = this._items[0] as SkillRuneHandbookTabItem;
            }
            this._curItem.selectedIndex = arg1;
            return;
        }

        public expandItem(arg1: int): void
        {
            var loc2=null;
            var loc1=0;
            while (loc1 < this._items.length) 
            {
                loc2 = this._items[loc1] as SkillRuneHandbookTabItem;
                if (loc2.type != arg1) 
                {
                    loc2.shrinItem();
                }
                else 
                {
                    loc2.expandItem();
                    this._curItem = loc2;
                }
                ++loc1;
            }
            this.updatePlace();
            return;
        }

        public shrinItem(arg1: int): void
        {
            var loc2=null;
            var loc1=0;
            while (loc1 < this._items.length) 
            {
                loc2 = this._items[loc1] as SkillRuneHandbookTabItem;
                if (loc2.type == arg1) 
                {
                    loc2.shrinItem();
                    this._curItem = loc2;
                }
                ++loc1;
            }
            this.updatePlace();
            return;
        }

        /* internal  */updatePlace(): void
        {
            var loc1=null;
            var loc3=null;
            loc1 = this._items[0];
            loc1.x = 6;
            loc1.y = 6;
            var loc2=1;
            while (loc2 < this._items.length) 
            {
                loc3 = this._items[loc2] as SkillRuneHandbookTabItem;
                loc3.y = loc1.y + loc1.myHeight + 5;
                loc3.x = loc1.x;
                loc1 = loc3;
                ++loc2;
            }
            return;
        }

        /* internal  */initView(): void
        {
            ObjCreate.createBg(0, 0, 164, 440, this);
            return;
        }

        /* internal */ /* var */_items: Array<any>;

        /* internal */ /* var */_curItem: SkillRuneHandbookTabItem;
    }
